<template>
    <view class="layout">
        <DemoChild ref="child">
			
		</DemoChild>
		<button @click="update">点击修改子值</button>
        <button @click="navigateToDemo4">跳转到Demo4</button>
		<button @click="navigateToDemo6">跳转到Demo6</button>
    </view>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app'

const child = ref(null);

function update() {
	child.value.updateCount()
}

function navigateToDemo4() {
	// 关闭当前页面，跳转到demo4
    uni.reLaunch({
        url: `/pages/demo4/demo4`
    })
}

function navigateToDemo6() {
    const params = {
        name: '张三',
        age: 18
    }
    uni.navigateTo({
        url: `/pages/demo6/demo6?params=${encodeURIComponent(JSON.stringify(params))}`
    })
}

onMounted(()=> {
	console.log(child.value)
})

onUnload(() => {
    console.log('onUnload卸载页面')
})

</script>

<style lang="scss" scoped>

</style>